import SwiftUI

struct SettingsView: View {
    @EnvironmentObject var authManager: AuthManager
    @Environment(\.presentationMode) var presentationMode
    
    var body: some View {
        NavigationView {
            List {
                Section(header: Text("账号信息")) {
                    if let user = authManager.currentUser {
                        HStack {
                            Text("用户名")
                            Spacer()
                            Text(user.username)
                                .foregroundColor(.gray)
                        }
                        
                        HStack {
                            Text("邮箱")
                            Spacer()
                            Text(user.email)
                                .foregroundColor(.gray)
                        }
                    }
                }
                
                Section(header: Text("应用设置")) {
                    NavigationLink(destination: Text("通知设置").font(.largeTitle)) {
                        Text("通知设置")
                    }
                    
                    NavigationLink(destination: Text("隐私政策").font(.largeTitle)) {
                        Text("隐私政策")
                    }
                    
                    NavigationLink(destination: Text("关于我们").font(.largeTitle)) {
                        Text("关于我们")
                    }
                }
                
                Section {
                    Button(action: {
                        authManager.logout()
                        presentationMode.wrappedValue.dismiss()
                    }) {
                        Text("退出登录")
                            .foregroundColor(.red)
                    }
                }
            }
            .listStyle(InsetGroupedListStyle())
            .navigationTitle("设置")
            .navigationBarItems(trailing: Button(action: {
                presentationMode.wrappedValue.dismiss()
            }) {
                Text("完成")
            })
        }
    }
}